import Vue from 'vue'
import VueRouter from 'vue-router'
import  login  from '../views/login.vue'

Vue.use(VueRouter)
let originalpush = VueRouter.prototype.push;
VueRouter.prototype.push = function(location){
  return originalpush.call(this,location).catch(err=>err)
}
const routes = [
  {
    path: '/',
    name: 'login',
    component: login
  },
  {
    path:'/dashbord',
    name:'dashbord',
    component:()=>import("@/components/dashbord.vue"),
    children:[
      {
        path:"",
        name:"home",
        component:()=>import("@/components/home.vue"),
        meta:[]
      },
      {
      path:"/userlist",
      name:"userlist",
      component:()=>import("@/components/userlist.vue"),
      meta:["数据管理","用户列表"]
    },
    {
      path:"/shoplist",
      name:"shoplist",
      component:()=>import("@/components/shoplist.vue")
    },
    {
      path:"/foodlist",
      name:"foodlist",
      component:()=>import("@/components/foodlist.vue")
    },
    {
      path:"/ordrelist",
      name:"ordrelist",
      component:()=>import("@/components/ordrelist.vue")
    },
    {
      path:"/adminlist",
      name:"adminlist",
      component:()=>import("@/components/adminlist.vue")
    },
  ]
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
